
import axios from 'axios'
import { Commit } from 'vuex'

export const getAndCommit = async (url: string,  payload: any,commit: Commit ,mutationName?: string) => {
  const { data } = await axios.get(url,{params: payload})
  mutationName && commit(mutationName, data)
  return data
}

export const get = async (url: string,  payload: any) => {
  const { data } = await axios.get(url+payload)
  return data
}

export const postAndCommit = async (url: string,  payload: any,commit: Commit ,mutationName?: string) => {
  const { data } = await axios.post(url,payload)
  mutationName && commit(mutationName, data)
  return data
}

export default {
  getAndCommit, postAndCommit,get
}